/*
 *  $Id: Manager.cs 582 2009-06-29 14:20:35Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System;
using System.Collections.Generic;

namespace Ragima {
    public static class RaceManager {
        private static readonly Dictionary<Type, Race> races = new Dictionary<Type,Race>();
        private static readonly Dictionary<string, Race> uniqueRaces = new Dictionary<string,Race>();

        /// <summary>
        /// Получить расу указанного типа
        /// </summary>
        public static Race GetRace<T>() where T: Race, new() {
            if (races.ContainsKey(typeof(T))) return races[typeof(T)];
            Race race = new T();
            races.Add(typeof(T), race);
            return race;
        }

        public static Race GetUnique(CreatureCard card) {
            if (uniqueRaces.ContainsKey(card.Id)) return uniqueRaces[card.Id];
            Race race = new Races.Unique(card);
            uniqueRaces.Add(card.Id, race);
            return race;
        }
    }
}